/*
 * Copyright 2021-2030 itbox.com All right reserved. This software is the confidential and proprietary information
 * of itbox.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it
 * only in accordance with the terms of the license agreement you entered into with itbox.com.
 */
package cn.itbox.example.application.consumer;

import cn.hutool.json.JSONUtil;
import cn.itbox.example.domain.event.role.RoleCreateEvent;
import cn.itbox.example.domain.event.role.RoleDeleteEvent;
import cn.itbox.example.domain.event.role.RoleUpdateEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * @BelongProject springboot-study
 * @BelongPackage cn.itbox.example.application.event.role.subscribe
 * @Description TODO
 * @ClassName RoleEventHandler
 * @Author xingc
 * @Date 2023/11/28 18:25
 * @Version 1.0.0
 */
@Slf4j
@Component
public class RoleEventHandler {
    @TransactionalEventListener(fallbackExecution = true)
    public void handleEvent(RoleCreateEvent event) {
        //用户删除后，后续执行强相关的链式调用逻辑

        log.info("接收领域事件[{}] {}", event.getClass().getSimpleName(), JSONUtil.toJsonStr(event));
    }

    @TransactionalEventListener(fallbackExecution = true)
    public void handleEvent(RoleUpdateEvent event) {
        //用户删除后，后续执行强相关的链式调用逻辑

        log.info("接收领域事件[{}] {}", event.getClass().getSimpleName(), JSONUtil.toJsonStr(event));
    }

    @TransactionalEventListener(fallbackExecution = true)
    public void handleEvent(RoleDeleteEvent event) {
        //用户删除后，后续执行强相关的链式调用逻辑

        log.info("接收领域事件[{}] {}", event.getClass().getSimpleName(), JSONUtil.toJsonStr(event));
    }
}
